package com.working.libbase.dialog

import android.content.Context
import android.view.Gravity
import androidx.appcompat.app.AlertDialog

object Dialog {
    fun showConfirm(
        context: Context,
        title: String? = "温馨提示",
        message: String,
        okTitle: String = "确定",
        cancelTitle: String? = "取消",
        cancelable: Boolean = true,
        onOk: (() -> Unit)? = null,
        onCancel: (() -> Unit)? = null
    ) {
        AlertDialog.Builder(context).setTitle(title).setMessage(message)
            .setCancelable(cancelable)
            .setNegativeButton(cancelTitle) { _, _ -> onCancel?.invoke() }
            .setPositiveButton(okTitle) { _, _ -> onOk?.invoke() }
            .show().window?.run {
                attributes = attributes.apply {
                    width = (windowManager.defaultDisplay.width * 0.95).toInt()
                    gravity = Gravity.CENTER
                }
            }
//        CommonDialog(context)
//            .apply {
//                mTitle = title
//                mMessage = message
//                mHint = messageHint
//                mConfirmText = okTitle
//                mCancelText = cancelTitle
//                mOnConfirm = onOk
//                mOnCancel = onCancel
//                setCancelable(cancelable)
//            }.show()
    }
}